//
//  RootViewController.m
//  UI5_UIControl课后作业
//
//  Created by dllo on 15/11/12.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "RootViewController.h"
#import "ZombieView.h"
#import "TomCatView.h"
#import "SliderView.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    // 看僵尸好不好用
//    ZombieView *zombieV = [[ZombieView alloc] initWithFrame:self.view.frame];
//    [self.view addSubview:zombieV];
//    [zombieV release];
    
    UISegmentedControl *segmentC = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Zombie", @"TomCat", @"Slider", nil]];
    segmentC.frame = CGRectMake(90, 600, 200, 30);
    
    [self.view addSubview:segmentC];
    
    [segmentC addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    
    [segmentC release];
    
    
    
    
}


- (void)segmentAction:(UISegmentedControl *)sender
{
    if (0 == sender.selectedSegmentIndex) {
        ZombieView *zombieV = [[ZombieView alloc] initWithFrame:self.view.frame];
        [self.view addSubview:zombieV];
        [zombieV release];
        
    }
    if (1 == sender.selectedSegmentIndex) {
        TomCatView *tomV = [[TomCatView alloc] initWithFrame:self.view.frame];
        [self.view addSubview:tomV];
        [tomV release];
    }
    if (2 == sender.selectedSegmentIndex) {
        SliderView *sliderV = [[SliderView alloc] initWithFrame:self.view.frame];
        [self.view addSubview:sliderV];
        [sliderV release];
    }
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
